package inet.app.view.activity;

import inet.app.R;
import inet.app.common.XoSoConstants;
import inet.app.controller.connect.JsonParser;
import inet.app.controller.parser.Parser_Kqxs;
import inet.app.controller.request.Request;
import inet.app.model.lottery.GetLoto;
import inet.app.model.lottery.LotteryResult;
import inet.app.model.object.KqGiai_Item;
import inet.app.model.object.Veso_Item;
import inet.app.model.util.DateProc;
import inet.app.model.util.ProgressDialog;
import inet.app.model.util.Util;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collection;
import java.util.Iterator;
import android.app.Activity;
import android.app.Dialog;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.text.format.Time;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.TextView;
import android.widget.Toast;

/*public class VesoDetail extends BaseActivity implements OnClickListener*/
public class VesoDetail extends BaseFragmentActivity implements OnClickListener {
	private String code, listnumber = "", date;
	String nhamang = "";
	String khuyenkhich = "";
	private TextView tvVeso, tvKq1, tvKq2, tvfotter;
	private WebView webView;
	int start;
	boolean isTrung = false;
	String trunggiai = "";
	String kqDe = "";
	private TextView tvTitle;
	private Button btNghe, btPlay, btStop;
	Dialog dialog;
	private String rngay = null, rthang = null, rgiaidb = null, rgiai1 = null,
			rgiai2 = null, rgiai3 = null, rgiai4 = null, rgiai5 = null,
			rgiai6 = null, rgiai7 = null, rgiai8 = null;
	boolean dangnghe = false;
	private ProgressDialog pdia;
	int myYear, myMonth, myDay, myHour, myMinute;
	private ArrayList<String> listaudio = new ArrayList<String>();
	private Button bt_ThongKe;
	private Request request = new Request();
	private Parser_Kqxs parser = new Parser_Kqxs();
	ArrayList<KqGiai_Item> arraylist = new ArrayList<KqGiai_Item>();
	private String mangKQ, mangLo;
	private String[] listKQ;
	LotteryResult lotteryresult;
	int countclick = 0;
	String data[];
	String databuf[];
	String dau0, dau1, dau2, dau3, dau4, dau5, dau6, dau7, dau8, dau9;
	String duoi0, duoi1, duoi2, duoi3, duoi4, duoi5, duoi6, duoi7, duoi8,
			duoi9;
	String duoi_veso;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);

		setContentView(R.layout.veso_detail);
		pdia = new ProgressDialog(VesoDetail.this);
		initBase();
		getData();
		initScreen();
	}

	private void getData() {
		// TODO Auto-generated method stub
		Bundle rb = this.getIntent().getExtras();
		code = rb.getString("code");
		listnumber = rb.getString("listnumber");
		date = rb.getString("date");
		System.out.println("dữ liệu trả về =========>>  " + code + date
				+ listnumber);
		duoi_veso = "      " + listnumber.substring(0, listnumber.length());
	}

	private void initScreen() {
		// TODO Auto-generated method stub
		tvVeso = (TextView) findViewById(R.id.tvVeso);
		tvKq1 = (TextView) findViewById(R.id.tvKq1);
		tvKq2 = (TextView) findViewById(R.id.tvKq2);

		bt_ThongKe = (Button) findViewById(R.id.bt_ThongKe);
		tvTitle = (TextView) findViewById(R.id.tvTitle);
		tvTitle.setText(" Kết Quả Vé Số");

		webView = (WebView) findViewById(R.id.webView);
		btNghe = (Button) findViewById(R.id.btNghe);

		btPlay = (Button) findViewById(R.id.btPlay);
		btStop = (Button) findViewById(R.id.btStop);

		btPlay.setOnClickListener(this);
		btStop.setOnClickListener(this);
		// Set day, month, year
		Time time = new Time();
		time.setToNow();
		final Calendar cal = Calendar.getInstance();
		myYear = cal.get(Calendar.YEAR);
		myMonth = cal.get(Calendar.MONTH) + 1;
		myDay = cal.get(Calendar.DATE);
		// SET DATE CURRENT
		Calendar c = Calendar.getInstance();
		SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy");
		SimpleDateFormat df2 = new SimpleDateFormat("HH:mm");
		String timecurren = df2.format(c.getTime());
		// END SET TIME

		webView.setWebViewClient(new MyWebViewClient());
		webView.getSettings().setJavaScriptEnabled(true);
		webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
		webView.getSettings().setPluginsEnabled(true);
		webView.getSettings().setSupportMultipleWindows(true);
		webView.getSettings().setSupportZoom(false);
		webView.setVerticalScrollBarEnabled(true);
		webView.setHorizontalScrollBarEnabled(false);
		// ---------------------------------SEND REQUEST-----------------------
		sendrequest(code, date, date);
	}

	public void sendrequest(final String code, final String sdate,
			final String edate) {
		pdia.show();
		AsyncTask<Void, Integer, Void> myTask = new AsyncTask<Void, Integer, Void>() {
			protected Void doInBackground(Void... params) {
				// TODO Auto-generated method stub
				arraylist = parser.getList_Mt(request.getkqxs(code, sdate,
						edate));
				return null;
			}

			protected void onPostExecute(Void result) {
				super.onPreExecute();
				if (arraylist != null) {
					if (code.equals("XSTD")) {
						Load_data_webview_mb(arraylist);
					} else
						Load_data_webview(arraylist);
					pdia.dismiss();
				} else {
					webView.clearCache(true);
					webView.loadDataWithBaseURL(null, "", "text/html", "utf-8",
							null);
					pdia.dismiss();
					Util.showDialog(1, VesoDetail.this);
				}
			}
		};
		myTask.execute();
	}

	private void Load_data_webview_mb(ArrayList<KqGiai_Item> arraylist) {
		// TODO Auto-generated method stub
		// SetText TextView
		tvVeso.setText("Vé số của bạn: " + listnumber);
		// End
		dau0 = "";
		dau1 = "";
		dau2 = "";
		dau3 = "";
		dau4 = "";
		dau5 = "";
		dau6 = "";
		dau7 = "";
		dau8 = "";
		dau9 = "";
		duoi0 = "";
		duoi1 = "";
		duoi2 = "";
		duoi3 = "";
		duoi4 = "";
		duoi5 = "";
		duoi6 = "";
		duoi7 = "";
		duoi8 = "";
		duoi9 = "";
		String giaidb, giai1;
		if (arraylist.get(0).getGiaidb().equals(""))
			giaidb = ".....";
		else
			giaidb = arraylist.get(0).getGiaidb();
		// ĐỀ
		kqDe = giaidb.substring(giaidb.length() - 2, giaidb.length());

		if (arraylist.get(0).getGiai1().equals(""))
			giai1 = ".....";
		else
			giai1 = arraylist.get(0).getGiai1();

		String[] giai2 = (arraylist.get(0).getGiai2() + "-.....-.....-")
				.split("-");
		String[] giai3 = (arraylist.get(0).getGiai3() + "-.....-.....-.....-.....-.....-.....-")
				.split("-");
		String[] giai4 = (arraylist.get(0).getGiai4() + "-.....-.....-.....-.....-")
				.split("-");
		String[] giai5 = (arraylist.get(0).getGiai5() + "-.....-.....-.....-.....-.....-.....-")
				.split("-");
		String[] giai6 = (arraylist.get(0).getGiai6() + "-.....-.....-.....-")
				.split("-");
		String[] giai7 = (arraylist.get(0).getGiai7() + "-.....-.....-.....-.....-")
				.split("-");

		// ---------------------------------- Parser DAU
		// DUOI-----------------------------------//
		lotteryresult = new LotteryResult(giaidb, giai1, arraylist.get(0)
				.getGiai2(), arraylist.get(0).getGiai3(), arraylist.get(0)
				.getGiai4(), arraylist.get(0).getGiai5(), arraylist.get(0)
				.getGiai6(), arraylist.get(0).getGiai7());
		Result_Veso(lotteryresult, kqDe);

		GetLoto getloto = new GetLoto();
		String numberfirts, numberend;
		Collection<String> cEndNumbers = getloto.getEndNumberOfLotteryResult(
				lotteryresult, 2);
		String endNumber = "";
		for (Iterator<String> it = cEndNumbers.iterator(); it.hasNext();) {
			endNumber = it.next();
			numberfirts = Character.toString(endNumber.charAt(0));
			numberend = Character.toString(endNumber.charAt(1));

			// ĐẦU
			if (numberfirts.equals("0") == true)
				dau0 += endNumber.substring(1, 2) + " ";
			if (numberfirts.equals("1") == true)
				dau1 += endNumber.substring(1, 2) + " ";
			if (numberfirts.equals("2") == true)
				dau2 += endNumber.substring(1, 2) + " ";
			if (numberfirts.equals("3") == true)
				dau3 += endNumber.substring(1, 2) + " ";
			if (numberfirts.equals("4") == true)
				dau4 += endNumber.substring(1, 2) + " ";
			if (numberfirts.equals("5") == true)
				dau5 += endNumber.substring(1, 2) + " ";
			if (numberfirts.equals("6") == true)
				dau6 += endNumber.substring(1, 2) + " ";
			if (numberfirts.equals("7") == true)
				dau7 += endNumber.substring(1, 2) + " ";
			if (numberfirts.equals("8") == true)
				dau8 += endNumber.substring(1, 2) + " ";
			if (numberfirts.equals("9") == true)
				dau9 += endNumber.substring(1, 2) + " ";

			// ĐUÔI
			if (numberend.equals("0") == true)
				duoi0 += endNumber.substring(0, 1) + " ";
			if (numberend.equals("1") == true)
				duoi1 += endNumber.substring(0, 1) + " ";
			if (numberend.equals("2") == true)
				duoi2 += endNumber.substring(0, 1) + " ";
			if (numberend.equals("3") == true)
				duoi3 += endNumber.substring(0, 1) + " ";
			if (numberend.equals("4") == true)
				duoi4 += endNumber.substring(0, 1) + " ";
			if (numberend.equals("5") == true)
				duoi5 += endNumber.substring(0, 1) + " ";
			if (numberend.equals("6") == true)
				duoi6 += endNumber.substring(0, 1) + " ";
			if (numberend.equals("7") == true)
				duoi7 += endNumber.substring(0, 1) + " ";
			if (numberend.equals("8") == true)
				duoi8 += endNumber.substring(0, 1) + " ";
			if (numberend.equals("9") == true)
				duoi9 += endNumber.substring(0, 1) + " ";
		}
		// Clear the cache
		if (isTrung) {
			tvKq1.setText("Trúng:");
			tvKq2.setText("- " + trunggiai);
		} else {
			tvKq1.setText("Rất tiếc bạn không trúng giải!");
			tvKq2.setText("Chúc bạn may mắn lần sau!");
		}

		webView.clearCache(true);
		String htmlKetqua = "", htmlfooter = "";
		int dauDe = 0, duoiDe = 0;
		if (!kqDe.contains("..") && kqDe != null) {
			dauDe = Integer.parseInt(kqDe.substring(0, 1));
			duoiDe = Integer.parseInt(kqDe.substring(1));
		}
		switch (dauDe) {
		case 0:
			dau0 = dau0.replaceAll(duoiDe + "", "<span style=\'color:red;\'>"
					+ duoiDe + "</span>");
			break;
		case 1:
			dau1 = dau1.replaceAll(duoiDe + "", "<span style=\'color:red;\'>"
					+ duoiDe + "</span>");
			break;
		case 2:
			dau2 = dau2.replaceAll(duoiDe + "", "<span style=\'color:red;\'>"
					+ duoiDe + "</span>");
			break;
		case 3:
			dau3 = dau3.replaceAll(duoiDe + "", "<span style=\'color:red;\'>"
					+ duoiDe + "</span>");
			break;
		case 4:
			dau4 = dau4.replaceAll(duoiDe + "", "<span style=\'color:red;\'>"
					+ duoiDe + "</span>");
			break;
		case 5:
			dau5 = dau5.replaceAll(duoiDe + "", "<span style=\'color:red;\'>"
					+ duoiDe + "</span>");
			break;
		case 6:
			dau6 = dau6.replaceAll(duoiDe + "", "<span style=\'color:red;\'>"
					+ duoiDe + "</span>");
			break;
		case 7:
			dau7 = dau7.replaceAll(duoiDe + "", "<span style=\'color:red;\'>"
					+ duoiDe + "</span>");
			break;
		case 8:
			dau8 = dau8.replaceAll(duoiDe + "", "<span style=\'color:red;\'>"
					+ duoiDe + "</span>");
			break;
		case 9:
			dau9 = dau9.replaceAll(duoiDe + "", "<span style=\'color:red;\'>"
					+ duoiDe + "</span>");
			break;
		default:
			break;
		}

		switch (duoiDe) {
		case 0:
			duoi0 = duoi0.replaceAll(dauDe + "", "<span style=\'color:red;\'>"
					+ dauDe + "</span>");
			break;
		case 1:
			duoi1 = duoi1.replaceAll(dauDe + "", "<span style=\'color:red;\'>"
					+ dauDe + "</span>");
			break;
		case 2:
			duoi2 = dau2.replaceAll(dauDe + "", "<span style=\'color:red;\'>"
					+ dauDe + "</span>");
			break;
		case 3:
			duoi3 = duoi3.replaceAll(dauDe + "", "<span style=\'color:red;\'>"
					+ dauDe + "</span>");
			break;
		case 4:
			duoi4 = duoi4.replaceAll(dauDe + "", "<span style=\'color:red;\'>"
					+ dauDe + "</span>");
			break;
		case 5:
			duoi5 = duoi5.replaceAll(dauDe + "", "<span style=\'color:red;\'>"
					+ dauDe + "</span>");
			break;
		case 6:
			duoi6 = duoi6.replaceAll(dauDe + "", "<span style=\'color:red;\'>"
					+ dauDe + "</span>");
			break;
		case 7:
			duoi7 = duoi7.replaceAll(dauDe + "", "<span style=\'color:red;\'>"
					+ dauDe + "</span>");
			break;
		case 8:
			duoi8 = duoi8.replaceAll(dauDe + "", "<span style=\'color:red;\'>"
					+ dauDe + "</span>");
			break;
		case 9:
			duoi9 = duoi9.replaceAll(dauDe + "", "<span style=\'color:red;\'>"
					+ dauDe + "</span>");
			break;
		default:
			break;
		}

		htmlKetqua += "<div>"
				+ "<div  style=\"cursor: pointer; margin:3px 0 0 0; background-color:#323232;width: 100%\">"
				+ "<input style=\"background-color:#323232; color:#ffffff; height:30px; width:100%; font-size:11px; font-weight:bold; float:right; position:relative;\" type=\"button\" name=\"desel\" value=\""
				+ "CLICK NHẬN KẾT QUẢ XỔ SỐ "
				+ arraylist.get(0).getName()
				+ "\" onclick=\"window.location.href='"
				+ arraylist.get(0).getCode()
				+ "'\" >"
				+ "</div>"
				+ "<div>"
				+ "<table width=\"100%\" border='0' cellspacing=\"1\" cellpadding=\"0\">"
				+ "<tr>"
				+ "<td width=\"75%\" valign=\"top\" colspan=\"12\">"
				+ "<table width=\"100%\"  border=\"0\" bgcolor=\"#CCCCCC\" cellspacing=\"1\" cellpadding=\"0\">"
				+ "<tr bgcolor=\"#FFFFFF\">"
				+ "<td width=\"10%\" height=\"40\"  align=\"center\" class=\"right\" style=\"color:red;  \" colspan=\"12\" >"
				+ "<img src=\"file:///android_res/drawable/img_db.png\" width=\"35\" height=\"35\"/>"
				+ "<td width=\"90%\"  align=\"center\" style=\"color:red;\" colspan=\"12\"><span style=\"background-color:"
				+ (!duoi_veso.trim().substring(duoi_veso.trim().length() - 2)
						.contains(kqDe) ? "while" : "#00CCFF")
				+ ";\";padding: 0px 5px 0px 5px;\">"
				+ giaidb
				+ "</span></td>"
				+ "</tr>"
				+ "<tr bgcolor=\"#FFFFFF\">"
				+ "<td width=\"10%\" height=\"30\"  align=\"center\" class=\"fontsize12 black-text1\" colspan=\"12\">"
				+ "<img src=\"file:///android_res/drawable/img_g1.png\" width=\"35\" height=\"35\"/>"
				+ "<td class=\"fontsize14a black-text5\" align=\"center\" style=\"color:black;\" colspan=\"12\"><span style=\"background-color:"
				+ (!duoi_veso
						.substring(duoi_veso.length() - giai1.length(),
								duoi_veso.length()).trim().contains(giai1) ? "while"
						: "#00CCFF")
				+ ";\";padding: 0px 5px 0px 5px;\">"
				+ giai1
				+ "</span></td>"
				+ "</tr>"
				+ "<tr bgcolor=\"#FFFFFF\">"
				+ "<td height=\"30\"  align=\"center\" class=\"left\" colspan=\"12\">"
				+ "<img src=\"file:///android_res/drawable/img_g2.png\" width=\"35\" height=\"35\"/>"
				+ "<td class=\"right\" width=\"50%\" align=\"center\" style=\"color:black;\" colspan=\"6\"><span style=\"background-color:"
				+ (!duoi_veso
						.substring(duoi_veso.length() - giai2[0].length(),
								duoi_veso.length()).trim().contains(giai2[0]) ? "while"
						: "#00CCFF")
				+ ";\";padding: 0px 5px 0px 5px;\">"
				+ giai2[0]
				+ "</span></td>"
				+ "<td class=\"right\" width=\"50%\" align=\"center\" style=\"color:black;\" colspan=\"6\"><span style=\"background-color:"
				+ (!duoi_veso
						.substring(duoi_veso.length() - giai2[1].length(),
								duoi_veso.length()).trim().contains(giai2[1]) ? "while"
						: "#00CCFF")
				+ ";\";padding: 0px 5px 0px 5px;\">"
				+ giai2[1]
				+ "</span></td>"
				+ "</tr>"
				+

				"<tr bgcolor=\"#FFFFFF\" height=\"30\">"
				+ "<td height=\"30\"   align=\"center\" class=\"fontsize12 black-text1\" rowspan=\"2\" colspan=\"12\">"
				+ "<img src=\"file:///android_res/drawable/img_giai3.png\" width=\"35\" height=\"70\"/>"
				+ "<td class=\"fontsize14a black-text5\" width=\"30%\" style=\"padding: 5px 0pt;\" align=\"center\" style=\"color:black;\" colspan=\"4\"><span style=\"background-color:"
				+ (!duoi_veso
						.substring(duoi_veso.length() - giai3[0].length(),
								duoi_veso.length()).trim().contains(giai3[0]) ? "while"
						: "#00CCFF")
				+ ";\";padding: 0px 5px 0px 5px;\">"
				+ giai3[0]
				+ "</span></td>"
				+ "<td class=\"right\" align=\"center\" width=\"30%\" style=\"color:black;\" colspan=\"4\"><span style=\"background-color:"
				+ (!duoi_veso
						.substring(duoi_veso.length() - giai3[1].length(),
								duoi_veso.length()).trim().contains(giai3[1]) ? "while"
						: "#00CCFF")
				+ ";\";padding: 0px 5px 0px 5px;\">"
				+ giai3[1]
				+ "</span></td>"
				+ "<td class=\"right\" align=\"center\" width=\"30%\" style=\"color:black;\" colspan=\"4\"><span style=\"background-color:"
				+ (!duoi_veso
						.substring(duoi_veso.length() - giai3[2].length(),
								duoi_veso.length()).trim().contains(giai3[2]) ? "while"
						: "#00CCFF")
				+ ";\";padding: 0px 5px 0px 5px;\">"
				+ giai3[2]
				+ "</span></td>"
				+ "</tr>"
				+

				" <tr bgcolor=\"#FFFFFF\" height=\"30\" > "
				+ "<td height=\"30\" class=\"right\" width=\"30%\" align=\"center\" style=\"color:black;\" colspan=\"4\"> <span style=\"background-color:"
				+ (!duoi_veso
						.substring(duoi_veso.length() - giai3[3].length(),
								duoi_veso.length()).trim().contains(giai3[3]) ? "while"
						: "#00CCFF")
				+ ";\";padding: 0px 5px 0px 5px;\">"
				+ giai3[3]
				+ "</span></td>"
				+ "<td class=\"right\" align=\"center\" width=\"30%\" style=\"color:black;\" colspan=\"4\"><span style=\"background-color:"
				+ (!duoi_veso
						.substring(duoi_veso.length() - giai3[4].length(),
								duoi_veso.length()).trim().contains(giai3[4]) ? "while"
						: "#00CCFF")
				+ ";\";padding: 0px 5px 0px 5px;\">"
				+ giai3[4]
				+ "</span></td>"
				+ "<td class=\"right\" align=\"center\" width=\"30%\" style=\"color:black;\" colspan=\"4\"><span style=\"background-color:"
				+ (!duoi_veso
						.substring(duoi_veso.length() - giai3[5].length(),
								duoi_veso.length()).trim().contains(giai3[5]) ? "while"
						: "#00CCFF")
				+ ";\";padding: 0px 5px 0px 5px;\">"
				+ giai3[5]
				+ "</span></td>"
				+ "</tr>"
				+

				"<tr bgcolor=\"#FFFFFF\">"
				+ "<td height=\"30\" align=\"center\" class=\"left\" colspan=\"12\">"
				+ "<img src=\"file:///android_res/drawable/img_g4.png\" width=\"35\" height=\"35\"/>"
				+ "<td height=\"30\" class=\"right\" width=\"25%\" align=\"center\" style=\"color:black;\" colspan=\"3\"><span style=\"background-color:"
				+ (!duoi_veso
						.substring(duoi_veso.length() - giai4[0].length(),
								duoi_veso.length()).trim().contains(giai4[0]) ? "while"
						: "#00CCFF")
				+ ";\";padding: 0px 5px 0px 5px;\">"
				+ giai4[0]
				+ "</span></td>"
				+ "<td class=\"right\" align=\"center\" width=\"25%\" style=\"color:black;\" colspan=\"3\"><span style=\"background-color:"
				+ (!duoi_veso
						.substring(duoi_veso.length() - giai4[1].length(),
								duoi_veso.length()).trim().contains(giai4[1]) ? "while"
						: "#00CCFF")
				+ ";\";padding: 0px 5px 0px 5px;\"> "
				+ giai4[1]
				+ "</span></td>"
				+ "<td class=\"right\" align=\"center\" width=\"25%\" style=\"color:black;\" colspan=\"3\"><span style=\"background-color:"
				+ (!duoi_veso
						.substring(duoi_veso.length() - giai4[2].length(),
								duoi_veso.length()).trim().contains(giai4[2]) ? "while"
						: "#00CCFF")
				+ ";\";padding: 0px 5px 0px 5px;\">"
				+ giai4[2]
				+ "</span></td>"
				+ "<td class=\"right\" align=\"center\" width=\"25%\" style=\"color:black;\" colspan=\"3\"><span style=\"background-color:"
				+ (!duoi_veso
						.substring(duoi_veso.length() - giai4[3].length(),
								duoi_veso.length()).trim().contains(giai4[3]) ? "while"
						: "#00CCFF")
				+ ";\";padding: 0px 5px 0px 5px;\">"
				+ giai4[3]
				+ "</span></td>"
				+ "</tr>"
				+

				"<tr bgcolor=\"#FFFFFF\" height=\"30\">"
				+ "<td height=\"30\"  align=\"center\" class=\"left\" rowspan=\"2\" colspan=\"12\">"
				+ "<img src=\"file:///android_res/drawable/img_giai5.png\" width=\"35\" height=\"70\"/>"
				+ "<td class=\"right\" align=\"center\" width=\"30%\" style=\"color:black;\" colspan=\"4\"><span style=\"background-color:"
				+ (!duoi_veso
						.substring(duoi_veso.length() - giai5[0].length(),
								duoi_veso.length()).trim().contains(giai5[0]) ? "while"
						: "#00CCFF")
				+ ";\";padding: 0px 5px 0px 5px;\">"
				+ giai5[0]
				+ "</span></td>"
				+ "<td class=\"right\" align=\"center\" width=\"30%\" style=\"color:black;\" colspan=\"4\"><span style=\"background-color:"
				+ (!duoi_veso
						.substring(duoi_veso.length() - giai5[1].length(),
								duoi_veso.length()).trim().contains(giai5[1]) ? "while"
						: "#00CCFF")
				+ ";\";padding: 0px 5px 0px 5px;\">"
				+ giai5[1]
				+ "</span></td>"
				+ "<td class=\"right\" align=\"center\" width=\"30%\" style=\"color:black;\" colspan=\"4\"><span style=\"background-color:"
				+ (!duoi_veso
						.substring(duoi_veso.length() - giai5[2].length(),
								duoi_veso.length()).trim().contains(giai5[2]) ? "while"
						: "#00CCFF")
				+ ";\";padding: 0px 5px 0px 5px;\">"
				+ giai5[2]
				+ "</span></td>"
				+ "</tr>"
				+ " <tr bgcolor=\"#FFFFFF\" height=\"30\"> "
				+ "<td height=\"30\" class=\"right\" align=\"center\" width=\"30%\" style=\"color:black;\" colspan=\"4\"><span style=\"background-color:"
				+ (!duoi_veso
						.substring(duoi_veso.length() - giai5[3].length(),
								duoi_veso.length()).trim().contains(giai5[3]) ? "while"
						: "#00CCFF")
				+ ";\";padding: 0px 5px 0px 5px;\">"
				+ giai5[3]
				+ "</span></td>"
				+ "<td class=\"right\" align=\"center\" width=\"30%\" style=\"color:black;\" colspan=\"4\"><span style=\"background-color:"
				+ (!duoi_veso
						.substring(duoi_veso.length() - giai5[4].length(),
								duoi_veso.length()).trim().contains(giai5[4]) ? "while"
						: "#00CCFF")
				+ ";\";padding: 0px 5px 0px 5px;\">"
				+ giai5[4]
				+ "</span></td>"
				+ "<td class=\"right\" align=\"center\" width=\"30%\" style=\"color:black;\" colspan=\"4\"><span style=\"background-color:"
				+ (!duoi_veso
						.substring(duoi_veso.length() - giai5[5].length(),
								duoi_veso.length()).trim().contains(giai5[5]) ? "while"
						: "#00CCFF")
				+ ";\";padding: 0px 5px 0px 5px;\">"
				+ giai5[5]
				+ "</span></td>"
				+ "</tr>"
				+ "<tr bgcolor=\"#FFFFFF\">"
				+ "<td height=\"30\"  align=\"center\" class=\"fontsize12 black-text1\" colspan=\"12\">"
				+ "<img src=\"file:///android_res/drawable/img_g6.png\" width=\"35\" height=\"35\"/>"
				+ "<td class=\"fontsize14a black-text5\" width=\"30%\" align=\"center\" style=\"color:black;\" colspan=\"4\"><span style=\"background-color:"
				+ (!duoi_veso
						.substring(duoi_veso.length() - giai6[0].length(),
								duoi_veso.length()).trim().contains(giai6[0]) ? "while"
						: "#00CCFF")
				+ ";\";padding: 0px 5px 0px 5px;\">"
				+ giai6[0]
				+ "</span></td>"
				+ "<td class=\"right\" align=\"center\" width=\"30%\" style=\"color:black;\" colspan=\"4\"><span style=\"background-color:"
				+ (!duoi_veso
						.substring(duoi_veso.length() - giai6[1].length(),
								duoi_veso.length()).trim().contains(giai6[1]) ? "while"
						: "#00CCFF")
				+ ";\";padding: 0px 5px 0px 5px;\">"
				+ giai6[1]
				+ "</span></td>"
				+ "<td class=\"right\" align=\"center\" width=\"30%\" style=\"color:black;\" colspan=\"4\"><span style=\"background-color:"
				+ (!duoi_veso
						.substring(duoi_veso.length() - giai6[2].length(),
								duoi_veso.length()).trim().contains(giai6[2]) ? "while"
						: "#00CCFF")
				+ ";\";padding: 0px 5px 0px 5px;\">"
				+ giai6[2]
				+ "</span></td>"
				+ "</tr>"
				+ "<tr bgcolor=\"#FFFFFF\">"
				+ "<td height=\"30\"  align=\"center\" class=\"fontsize12 black-text1\" colspan=\"12\">"
				+ "<img src=\"file:///android_res/drawable/img_g7.png\" width=\"35\" height=\"35\"/>"
				+ "<td class=\"fontsize14a black-text5\" width=\"25%\" align=\"center\" style=\"color:black;\" colspan=\"3\"><span style=\"background-color:"
				+ (!duoi_veso
						.substring(duoi_veso.length() - giai7[0].length(),
								duoi_veso.length()).trim().contains(giai7[0]) ? "while"
						: "#00CCFF")
				+ ";\";padding: 0px 5px 0px 5px;\">"
				+ giai7[0]
				+ "</span></td>"
				+ "<td class=\"right\" align=\"center\" width=\"25%\" style=\"color:black;\" colspan=\"3\"><span style=\"background-color:"
				+ (!duoi_veso
						.substring(duoi_veso.length() - giai7[1].length(),
								duoi_veso.length()).trim().contains(giai7[1]) ? "while"
						: "#00CCFF")
				+ ";\";padding: 0px 5px 0px 5px;\"> "
				+ giai7[1]
				+ "</span></td>"
				+ "<td class=\"right\" align=\"center\" width=\"25%\" style=\"color:black;\" colspan=\"3\"><span style=\"background-color:"
				+ (!duoi_veso
						.substring(duoi_veso.length() - giai7[2].length(),
								duoi_veso.length()).trim().contains(giai7[2]) ? "while"
						: "#00CCFF")
				+ ";\";padding: 0px 5px 0px 5px;\">"
				+ giai7[2]
				+ "</span></td>"
				+ "<td class=\"right\" align=\"center\" width=\"25%\" style=\"color:black;\" colspan=\"3\"><span style=\"background-color:"
				+ (!duoi_veso
						.substring(duoi_veso.length() - giai7[3].length(),
								duoi_veso.length()).trim().contains(giai7[3]) ? "while"
						: "#00CCFF")
				+ ";\";padding: 0px 5px 0px 5px;\">"
				+ giai7[3]
				+ "</span></td>"
				+ "</tr>"
				+ "</table>"
				+ "</td>"
				+ "</tr>" + "</table>" + "</div>";

		String htmldauduoi = "";
		htmldauduoi += "<div>"
				+ "<table width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"0\">"
				+ "<tr>"
				+ "<td width=\"50%\" valign=\"top\" colspan=\"12\">"
				+ "<table width=\"100%\"  border=\"0\" bgcolor=\"#CCCCCC\" cellspacing=\"1\" cellpadding=\"0\">"
				+

				"<tr bgcolor=\"#323232\" >"
				+ "<td width=\"10%\" height=\"35\"  align=\"center\" class=\"right\" style=\"color:#ffffff;\" colspan=\"12\" >Đầu</td>"
				+ "<td width=\"90%\" height=\"35\"  align=\"center\" class=\"right\" style=\"color:#ffffff;\" colspan=\"12\" >Lô Tô</td>"
				+ "</tr>"
				+ "<tr bgcolor=\"#FFFFFF\" >"
				+ "<td width=\"10%\" height=\"25\"  align=\"center\" class=\"right\" style=\"color:"
				+ (dauDe != 0 ? "black" : "red")
				+ ";\" colspan=\"12\" >"
				+ "<img src=\"file:///android_res/drawable/img_g0.png\" width=\"30\" height=\"30\"/>"
				+ "<td width=\"90%\" height=\"25\"  align=\"left\" class=\"right\" style=\"color:back;padding-left:5px;\" colspan=\"12\" >"
				+ dau0
				+ "</td>"
				+ "</tr>"
				+ "<tr bgcolor=\"#FFFFFF\" >"
				+ "<td width=\"10%\" height=\"25\"  align=\"center\" class=\"right\" style=\"color:"
				+ (dauDe != 1 ? "black" : "red")
				+ ";\" colspan=\"12\" >"
				+ "<img src=\"file:///android_res/drawable/img_g1.png\" width=\"30\" height=\"30\"/>"
				+ "<td width=\"90%\" height=\"25\"  align=\"left\" class=\"right\" style=\"color:back;padding-left:5px;\" colspan=\"12\" >"
				+ dau1
				+ "</td>"
				+ "</tr>"
				+ "<tr bgcolor=\"#FFFFFF\" >"
				+ "<td width=\"10%\" height=\"25\"  align=\"center\" class=\"right\" style=\"color:"
				+ (dauDe != 2 ? "black" : "red")
				+ ";\" colspan=\"12\" >"
				+ "<img src=\"file:///android_res/drawable/img_g2.png\" width=\"30\" height=\"30\"/>"
				+ "<td width=\"90%\" height=\"25\"  align=\"left\" class=\"right\" style=\"color:back;padding-left:5px;\" colspan=\"12\" >"
				+ dau2
				+ "</td>"
				+ "</tr>"
				+ "<tr bgcolor=\"#FFFFFF\" >"
				+ "<td width=\"10%\" height=\"25\"  align=\"center\" class=\"right\" style=\"color:"
				+ (dauDe != 3 ? "black" : "red")
				+ ";\" colspan=\"12\" >"
				+ "<img src=\"file:///android_res/drawable/img_g3.png\" width=\"30\" height=\"30\"/>"
				+ "<td width=\"90%\" height=\"25\"  align=\"left\" class=\"right\" style=\"color:back;padding-left:5px;\" colspan=\"12\" >"
				+ dau3
				+ "</td>"
				+ "</tr>"
				+ "<tr bgcolor=\"#FFFFFF\" >"
				+ "<td width=\"10%\" height=\"25\"  align=\"center\" class=\"right\" style=\"color"
				+ (dauDe != 4 ? "black" : "red")
				+ ";\" colspan=\"12\" >"
				+ "<img src=\"file:///android_res/drawable/img_g4.png\" width=\"30\" height=\"30\"/>"
				+ "<td width=\"90%\" height=\"25\"  align=\"left\" class=\"right\" style=\"color:back;padding-left:5px;\" colspan=\"12\" >"
				+ dau4
				+ "</td>"
				+ "</tr>"
				+ "<tr bgcolor=\"#FFFFFF\" >"
				+ "<td width=\"10%\" height=\"25\"  align=\"center\" class=\"right\" style=\"color:"
				+ (dauDe != 5 ? "black" : "red")
				+ ";\" colspan=\"12\" >"
				+ "<img src=\"file:///android_res/drawable/img_g5.png\" width=\"30\" height=\"30\"/>"
				+ "<td width=\"90%\" height=\"25\"  align=\"left\" class=\"right\" style=\"color:back;padding-left:5px;\" colspan=\"12\" >"
				+ dau5
				+ "</td>"
				+ "</tr>"
				+ "<tr bgcolor=\"#FFFFFF\" >"
				+ "<td width=\"10%\" height=\"25\"  align=\"center\" class=\"right\" style=\"color:"
				+ (dauDe != 6 ? "black" : "red")
				+ ";\" colspan=\"12\" >"
				+ "<img src=\"file:///android_res/drawable/img_g6.png\" width=\"30\" height=\"30\"/>"
				+ "<td width=\"90%\" height=\"25\"  align=\"left\" class=\"right\" style=\"color:back;padding-left:5px;\" colspan=\"12\" >"
				+ dau6
				+ "</td>"
				+ "</tr>"
				+ "<tr bgcolor=\"#FFFFFF\" >"
				+ "<td width=\"10%\" height=\"25\"  align=\"center\" class=\"right\" style=\"color:"
				+ (dauDe != 7 ? "black" : "red")
				+ ";\" colspan=\"12\" >"
				+ "<img src=\"file:///android_res/drawable/img_g7.png\" width=\"30\" height=\"30\"/>"
				+ "<td width=\"90%\" height=\"25\"  align=\"left\" class=\"right\" style=\"color:back;padding-left:5px;\" colspan=\"12\" >"
				+ dau7
				+ "</td>"
				+ "</tr>"
				+ "<tr bgcolor=\"#FFFFFF\" >"
				+ "<td width=\"10%\" height=\"25\"  align=\"center\" class=\"right\" style=\"color:"
				+ (dauDe != 8 ? "black" : "red")
				+ ";\" colspan=\"12\" >"
				+ "<img src=\"file:///android_res/drawable/img_g8.png\" width=\"30\" height=\"30\"/>"
				+ "<td width=\"90%\" height=\"25\"  align=\"left\" class=\"right\" style=\"color:back;padding-left:5px;\" colspan=\"12\" >"
				+ dau8
				+ "</td>"
				+ "</tr>"
				+ "<tr bgcolor=\"#FFFFFF\" >"
				+ "<td width=\"10%\" height=\"25\"  align=\"center\" class=\"right\" style=\"color:"
				+ (dauDe != 9 ? "black" : "red")
				+ ";\" colspan=\"12\" >"
				+ "<img src=\"file:///android_res/drawable/img_g9.png\" width=\"30\" height=\"30\"/>"
				+ "<td width=\"90%\" height=\"25\"  align=\"left\" class=\"right\" style=\"color:back;padding-left:5px;\" colspan=\"12\" >"
				+ dau9
				+ "</td>"
				+ "</tr>"
				+

				"</table>"
				+

				"</td>"

				+

				"<td width=\"50%\" valign=\"top\" colspan=\"12\">"
				+

				"<table width=\"100%\"  border=\"0\" bgcolor=\"#CCCCCC\" cellspacing=\"1\" cellpadding=\"0\" >"
				+

				"<tr bgcolor=\"#323232\">"
				+ "<td width=\"10%\" height=\"35\"  align=\"center\" class=\"right\" style=\"color:#ffffff;\" colspan=\"12\" >Đít</td>"
				+ "<td width=\"90%\" height=\"35\"  align=\"center\" class=\"right\" style=\"color:#ffffff;\" colspan=\"12\" >Lô Tô</td>"
				+ "</tr>"
				+

				"<tr bgcolor=\"#FFFFFF\" >"
				+ "<td width=\"10%\" height=\"25\"  align=\"center\" class=\"right\" style=\"color:"
				+ (duoiDe != 0 ? "black" : "red")
				+ ";\" colspan=\"12\" >"
				+ "<img src=\"file:///android_res/drawable/img_g0.png\" width=\"30\" height=\"30\"/>"
				+ "<td width=\"90%\" height=\"25\"  align=\"left\" class=\"right\" style=\"color:back;padding-left:5px;\" colspan=\"12\" >"
				+ duoi0
				+ "</td>"
				+ "</tr>"
				+ "<tr bgcolor=\"#FFFFFF\" >"
				+ "<td width=\"10%\" height=\"25\"  align=\"center\" class=\"right\" style=\"color:"
				+ (duoiDe != 1 ? "black" : "red")
				+ ";\" colspan=\"12\" >"
				+ "<img src=\"file:///android_res/drawable/img_g1.png\" width=\"30\" height=\"30\"/>"
				+ "<td width=\"90%\" height=\"25\"  align=\"left\" class=\"right\" style=\"color:back;padding-left:5px;\" colspan=\"12\" >"
				+ duoi1
				+ "</td>"
				+ "</tr>"
				+ "<tr bgcolor=\"#FFFFFF\" >"
				+ "<td width=\"10%\" height=\"25\"  align=\"center\" class=\"right\" style=\"color:"
				+ (duoiDe != 2 ? "black" : "red")
				+ ";\" colspan=\"12\" >"
				+ "<img src=\"file:///android_res/drawable/img_g2.png\" width=\"30\" height=\"30\"/>"
				+ "<td width=\"90%\" height=\"25\"  align=\"left\" class=\"right\" style=\"color:back;padding-left:5px;\" colspan=\"12\" >"
				+ duoi2
				+ "</td>"
				+ "</tr>"
				+ "<tr bgcolor=\"#FFFFFF\" >"
				+ "<td width=\"10%\" height=\"25\"  align=\"center\" class=\"right\" style=\"color:"
				+ (duoiDe != 3 ? "black" : "red")
				+ ";\" colspan=\"12\" >"
				+ "<img src=\"file:///android_res/drawable/img_g3.png\" width=\"30\" height=\"30\"/>"
				+ "<td width=\"90%\" height=\"25\"  align=\"left\" class=\"right\" style=\"color:back;padding-left:5px;\" colspan=\"12\" >"
				+ duoi3
				+ "</td>"
				+ "</tr>"
				+ "<tr bgcolor=\"#FFFFFF\" >"
				+ "<td width=\"10%\" height=\"25\"  align=\"center\" class=\"right\" style=\"color:"
				+ (duoiDe != 4 ? "black" : "red")
				+ ";\" colspan=\"12\" >"
				+ "<img src=\"file:///android_res/drawable/img_g4.png\" width=\"30\" height=\"30\"/>"
				+ "<td width=\"90%\" height=\"25\"  align=\"left\" class=\"right\" style=\"color:back;padding-left:5px;\" colspan=\"12\" >"
				+ duoi4
				+ "</td>"
				+ "</tr>"
				+ "<tr bgcolor=\"#FFFFFF\" >"
				+ "<td width=\"10%\" height=\"25\"  align=\"center\" class=\"right\" style=\"color:"
				+ (duoiDe != 5 ? "black" : "red")
				+ ";\" colspan=\"12\" >"
				+ "<img src=\"file:///android_res/drawable/img_g5.png\" width=\"30\" height=\"30\"/>"
				+ "<td width=\"90%\" height=\"25\"  align=\"left\" class=\"right\" style=\"color:back;padding-left:5px;\" colspan=\"12\" >"
				+ duoi5
				+ "</td>"
				+ "</tr>"
				+ "<tr bgcolor=\"#FFFFFF\" >"
				+ "<td width=\"10%\" height=\"25\"  align=\"center\" class=\"right\" style=\"color:"
				+ (duoiDe != 6 ? "black" : "red")
				+ ";\" colspan=\"12\" "
				+ "<img src=\"file:///android_res/drawable/img_g6.png\" width=\"30\" height=\"30\"/>"
				+ "<td width=\"90%\" height=\"25\"  align=\"left\" class=\"right\" style=\"color:back;padding-left:5px;\" colspan=\"12\" >"
				+ duoi6
				+ "</td>"
				+ "</tr>"
				+ "<tr bgcolor=\"#FFFFFF\" >"
				+ "<td width=\"10%\" height=\"25\"  align=\"center\" class=\"right\" style=\"color:"
				+ (duoiDe != 7 ? "black" : "red")
				+ ";\" colspan=\"12\" >"
				+ "<img src=\"file:///android_res/drawable/img_g7.png\" width=\"30\" height=\"30\"/>"
				+ "<td width=\"90%\" height=\"25\"  align=\"left\" class=\"right\" style=\"color:back;padding-left:5px;\" colspan=\"12\" >"
				+ duoi7
				+ "</td>"
				+ "</tr>"
				+ "<tr bgcolor=\"#FFFFFF\" >"
				+ "<td width=\"10%\" height=\"25\"  align=\"center\" class=\"right\" style=\"color:"
				+ (duoiDe != 8 ? "black" : "red")
				+ ";\" colspan=\"12\" >"
				+ "<img src=\"file:///android_res/drawable/img_g8.png\" width=\"30\" height=\"30\"/>"
				+ "<td width=\"90%\" height=\"25\"  align=\"left\" class=\"right\" style=\"color:back;padding-left:5px;\" colspan=\"12\" >"
				+ duoi8
				+ "</td>"
				+ "</tr>"
				+ "<tr bgcolor=\"#FFFFFF\" >"
				+ "<td width=\"10%\" height=\"25\"  align=\"center\" class=\"right\" style=\"color:"
				+ (duoiDe != 9 ? "black" : "red")
				+ ";\" colspan=\"12\" >"
				+ "<img src=\"file:///android_res/drawable/img_g9.png\" width=\"30\" height=\"30\"/>"
				+ "<td width=\"90%\" height=\"25\"  align=\"left\" class=\"right\" style=\"color:back;padding-left:5px;\" colspan=\"12\" >"
				+ duoi9 + "</td>" + "</tr>" + "</table>" +

				"</td>" +

				"</tr>" + "</table>" + "</div>";
		htmlfooter = "<div style=\"margin:0 0 0 0; background-color:#323232; height:35px; text-align:center;\">"
				+ "<span style=\"background-color:#323232; text-align:center; color:#ffffff; font-size:13px; position:relative; top:10px\" class=\"fontsize12\">"
				+ "<strong>"
				+ "Chơi xổ số kiến thiết ích nước lợi nhà !"
				+ "</strong></span>" + "</div>";
		// -------------
		webView.loadDataWithBaseURL("file:///android_asset/", XoSoConstants.css+
				htmlKetqua + htmldauduoi + htmlfooter+"</body></html>", "text/html", "utf-8",
				null);

	}

	private void Result_Veso(LotteryResult result, String khuyenkhich) {
		// TODO Auto-generated method stub
		GetLoto getloto = new GetLoto();
		String numberfirts, numberend;
		Collection<String> cEndNumbers = getloto
				.getEndNumberOfLotteryResult(result);
		String endNumber = "";
		duoi_veso = "      " + duoi_veso;
		if (khuyenkhich.contains(duoi_veso.substring(
				duoi_veso.length() - khuyenkhich.length(), duoi_veso.length())
				.trim())) {
			trunggiai = " Khuyến khích " + khuyenkhich;
			isTrung = true;
		}
		for (Iterator<String> it = cEndNumbers.iterator(); it.hasNext();) {
			endNumber = it.next();
			String sosanh = endNumber.split(": ")[1].toString();
			if (duoi_veso.substring(duoi_veso.length() - sosanh.length(),
					duoi_veso.length()).contains(sosanh)) {
				isTrung = true;
				trunggiai += " " + endNumber;
			}
		}
	}

	public void Load_data_webview(ArrayList<KqGiai_Item> arraylist) {
		// SetText TextView
		tvVeso.setText("Vé số của bạn: " + listnumber);
		dau0 = "";
		dau1 = "";
		dau2 = "";
		dau3 = "";
		dau4 = "";
		dau5 = "";
		dau6 = "";
		dau7 = "";
		dau8 = "";
		dau9 = "";
		duoi0 = "";
		duoi1 = "";
		duoi2 = "";
		duoi3 = "";
		duoi4 = "";
		duoi5 = "";
		duoi6 = "";
		duoi7 = "";
		duoi8 = "";
		duoi9 = "";
		// Set data on datepicker
		String ngay = arraylist.get(0).getDate();
		myDay = Integer.parseInt(ngay.split("/")[0]);
		myMonth = Integer.parseInt(ngay.split("/")[1]);
		myYear = Integer.parseInt(ngay.split("/")[2]);
		// end set

		String giaidb = arraylist.get(0).getGiaidb();
		// ĐỀ
		kqDe = giaidb.substring(giaidb.length() - 2, giaidb.length());

		String giai1 = arraylist.get(0).getGiai1();
		String giai2 = arraylist.get(0).getGiai2();
		String[] giai3 = arraylist.get(0).getGiai3().split("-");
		String[] giai4 = arraylist.get(0).getGiai4().split("-");
		String giai5 = arraylist.get(0).getGiai5();
		String[] giai6 = arraylist.get(0).getGiai6().split("-");
		String giai7 = arraylist.get(0).getGiai7();
		String giai8 = arraylist.get(0).getGiai8();

		// ---------------------------------- Parser DAU
		// DUOI-----------------------------------//
		lotteryresult = new LotteryResult(giaidb, giai1, giai2, arraylist
				.get(0).getGiai3(), arraylist.get(0).getGiai4(), giai5,
				arraylist.get(0).getGiai6(), giai7, giai8);
		Result_Veso(lotteryresult, kqDe);

		GetLoto getloto = new GetLoto();
		String numberfirts, numberend;
		Collection<String> cEndNumbers = getloto.getEndNumberOfLotteryResult(
				lotteryresult, 2);
		String endNumber = "";
		for (Iterator<String> it = cEndNumbers.iterator(); it.hasNext();) {
			endNumber = it.next();
			numberfirts = Character.toString(endNumber.charAt(0));
			numberend = Character.toString(endNumber.charAt(1));
			// ĐẦU
			if (numberfirts.equals("0") == true)
				dau0 += endNumber.substring(1, 2) + " ";
			if (numberfirts.equals("1") == true)
				dau1 += endNumber.substring(1, 2) + " ";
			if (numberfirts.equals("2") == true)
				dau2 += endNumber.substring(1, 2) + " ";
			if (numberfirts.equals("3") == true)
				dau3 += endNumber.substring(1, 2) + " ";
			if (numberfirts.equals("4") == true)
				dau4 += endNumber.substring(1, 2) + " ";
			if (numberfirts.equals("5") == true)
				dau5 += endNumber.substring(1, 2) + " ";
			if (numberfirts.equals("6") == true)
				dau6 += endNumber.substring(1, 2) + " ";
			if (numberfirts.equals("7") == true)
				dau7 += endNumber.substring(1, 2) + " ";
			if (numberfirts.equals("8") == true)
				dau8 += endNumber.substring(1, 2) + " ";
			if (numberfirts.equals("9") == true)
				dau9 += endNumber.substring(1, 2) + " ";
			// ĐUÔI
			if (numberend.equals("0") == true)
				duoi0 += endNumber.substring(0, 1) + " ";
			if (numberend.equals("1") == true)
				duoi1 += endNumber.substring(0, 1) + " ";
			if (numberend.equals("2") == true)
				duoi2 += endNumber.substring(0, 1) + " ";
			if (numberend.equals("3") == true)
				duoi3 += endNumber.substring(0, 1) + " ";
			if (numberend.equals("4") == true)
				duoi4 += endNumber.substring(0, 1) + " ";
			if (numberend.equals("5") == true)
				duoi5 += endNumber.substring(0, 1) + " ";
			if (numberend.equals("6") == true)
				duoi6 += endNumber.substring(0, 1) + " ";
			if (numberend.equals("7") == true)
				duoi7 += endNumber.substring(0, 1) + " ";
			if (numberend.equals("8") == true)
				duoi8 += endNumber.substring(0, 1) + " ";
			if (numberend.equals("9") == true)
				duoi9 += endNumber.substring(0, 1) + " ";
		}

		// Clear the cache
		if (isTrung) {
			tvKq1.setText("Trúng:");
			tvKq2.setText("- " + trunggiai);
		} else {
			tvKq1.setText("Rất tiếc bạn không trúng giải!");
			tvKq2.setText("Chúc bạn may mắn lần sau!");
		}

		webView.clearCache(true);
		String htmlKetqua = "", htmlfooter = "";
		int dauDe = 0, duoiDe = 0;
		if (!kqDe.contains("..") && kqDe != null) {
			dauDe = Integer.parseInt(kqDe.substring(0, 1));
			duoiDe = Integer.parseInt(kqDe.substring(1));
		}
		switch (dauDe) {
		case 0:
			dau0 = dau0.replaceAll(duoiDe + "", "<span style=\'color:red;\'>"
					+ duoiDe + "</span>");
			break;
		case 1:
			dau1 = dau1.replaceAll(duoiDe + "", "<span style=\'color:red;\'>"
					+ duoiDe + "</span>");
			break;
		case 2:
			dau2 = dau2.replaceAll(duoiDe + "", "<span style=\'color:red;\'>"
					+ duoiDe + "</span>");
			break;
		case 3:
			dau3 = dau3.replaceAll(duoiDe + "", "<span style=\'color:red;\'>"
					+ duoiDe + "</span>");
			break;
		case 4:
			dau4 = dau4.replaceAll(duoiDe + "", "<span style=\'color:red;\'>"
					+ duoiDe + "</span>");
			break;
		case 5:
			dau5 = dau5.replaceAll(duoiDe + "", "<span style=\'color:red;\'>"
					+ duoiDe + "</span>");
			break;
		case 6:
			dau6 = dau6.replaceAll(duoiDe + "", "<span style=\'color:red;\'>"
					+ duoiDe + "</span>");
			break;
		case 7:
			dau7 = dau7.replaceAll(duoiDe + "", "<span style=\'color:red;\'>"
					+ duoiDe + "</span>");
			break;
		case 8:
			dau8 = dau8.replaceAll(duoiDe + "", "<span style=\'color:red;\'>"
					+ duoiDe + "</span>");
			break;
		case 9:
			dau9 = dau9.replaceAll(duoiDe + "", "<span style=\'color:red;\'>"
					+ duoiDe + "</span>");
			break;

		default:
			break;
		}

		switch (duoiDe) {
		case 0:
			duoi0 = duoi0.replaceAll(dauDe + "", "<span style=\'color:red;\'>"
					+ dauDe + "</span>");
			break;
		case 1:
			duoi1 = duoi1.replaceAll(dauDe + "", "<span style=\'color:red;\'>"
					+ dauDe + "</span>");
			break;
		case 2:
			duoi2 = dau2.replaceAll(dauDe + "", "<span style=\'color:red;\'>"
					+ dauDe + "</span>");
			break;
		case 3:
			duoi3 = duoi3.replaceAll(dauDe + "", "<span style=\'color:red;\'>"
					+ dauDe + "</span>");
			break;
		case 4:
			duoi4 = duoi4.replaceAll(dauDe + "", "<span style=\'color:red;\'>"
					+ dauDe + "</span>");
			break;
		case 5:
			duoi5 = duoi5.replaceAll(dauDe + "", "<span style=\'color:red;\'>"
					+ dauDe + "</span>");
			break;
		case 6:
			duoi6 = duoi6.replaceAll(dauDe + "", "<span style=\'color:red;\'>"
					+ dauDe + "</span>");
			break;
		case 7:
			duoi7 = duoi7.replaceAll(dauDe + "", "<span style=\'color:red;\'>"
					+ dauDe + "</span>");
			break;
		case 8:
			duoi8 = duoi8.replaceAll(dauDe + "", "<span style=\'color:red;\'>"
					+ dauDe + "</span>");
			break;
		case 9:
			duoi9 = duoi9.replaceAll(dauDe + "", "<span style=\'color:red;\'>"
					+ dauDe + "</span>");
			break;

		default:
			break;
		}
		htmlKetqua += "<div  style=\"cursor: pointer; margin:3px 0 0 0; background-color:#323232;width: 100%\">"
				+ "<input style=\"background-color:#323232; color:#ffffff; height:30px; width:100%; font-size:11px; font-weight:bold; float:right; position:relative;\" type=\"button\" name=\"desel\" value=\""
				+ "CLICK NHẬN KẾT QUẢ XỔ SỐ "
				+ arraylist.get(0).getName()
				+ "\" onclick=\"window.location.href='"
				+ arraylist.get(0).getCode()
				+ "'\" >"
				+ "</div>"
				+ "<div><table width=\"100%\" border=\"0\" bgcolor=\"#CCCCCC\" cellspacing=\"1\"style=\"text-align:center;\" cellpadding=\"0\">"
				+ " <tr class=\"hienso\"  bgcolor=\"#FFFFFF\" height=\"30\"> <td class=\"left\" width=\"10%\">"
				+ "<img src=\"file:///android_res/drawable/img_g8.png\" width=\"35\" height=\"35\"/>"
				+ "<td class=\"right\" style=\"color:black;\" colspan=\"12\"><span style=\"background-color:"
				+ (!duoi_veso
						.substring(duoi_veso.length() - giai8.length(),
								duoi_veso.length()).trim().contains(giai8) ? "while"
						: "#00CCFF")
				+ ";\";padding: 0px 5px 0px 5px;\">"
				+ arraylist.get(0).getGiai8()
				+ "</span></td> </tr> "
				+ " <tr class=\"hienso\"  bgcolor=\"#FFFFFF\" height=\"30\"> <td class=\"left\">"
				+ "<img src=\"file:///android_res/drawable/img_g7.png\" width=\"35\" height=\"35\"/>"
				+ "<td class=\"right\" colspan=\"12\"><span style=\"background-color:"
				+ (!duoi_veso
						.substring(duoi_veso.length() - giai7.length(),
								duoi_veso.length()).trim().contains(giai7) ? "while"
						: "#00CCFF")
				+ ";\";padding: 0px 5px 0px 5px;\">"
				+ arraylist.get(0).getGiai7()
				+ "</span></td> </tr> "
				+ " <tr class=\"hienso\"  bgcolor=\"#FFFFFF\" height=\"30\"> <td class=\"left\" width=\"10%\">"
				+ "<img src=\"file:///android_res/drawable/img_g6.png\" width=\"35\" height=\"35\"/>"
				+ "<td class=\"right\" width=\"35%\" colspan=\"4\"><span style=\"background-color:"
				+ (!duoi_veso
						.substring(duoi_veso.length() - giai6[0].length(),
								duoi_veso.length()).trim().contains(giai6[0]) ? "while"
						: "#00CCFF")
				+ ";\";padding: 0px 5px 0px 5px;\">"
				+ giai6[0]
				+ "</span></td> <td class=\"right\" width=\"35%\"colspan=\"4\"><span style=\"background-color:"
				+ (!duoi_veso
						.substring(duoi_veso.length() - giai6[1].length(),
								duoi_veso.length()).trim().contains(giai6[1]) ? "while"
						: "#00CCFF")
				+ ";\";padding: 0px 5px 0px 5px;\">"
				+ giai6[1]
				+ "</span></td> <td class=\"right\" width=\"35%\"colspan=\"4\"><span style=\"background-color:"
				+ (!duoi_veso
						.substring(duoi_veso.length() - giai6[2].length(),
								duoi_veso.length()).trim().contains(giai6[2]) ? "while"
						: "#00CCFF")
				+ ";\";padding: 0px 5px 0px 5px;\">"
				+ giai6[2]
				+ "</span></td> </tr> "
				+ " <tr class=\"hienso\"  bgcolor=\"#FFFFFF\" height=\"30\"> <td class=\"left\">"
				+ "<img src=\"file:///android_res/drawable/img_g5.png\" width=\"35\" height=\"35\"/>"
				+ "<td class=\"right\" colspan=\"12\"><span style=\"background-color:"
				+ (!duoi_veso
						.substring(duoi_veso.length() - giai5.length(),
								duoi_veso.length()).trim().contains(giai5) ? "while"
						: "#00CCFF")
				+ ";\";padding: 0px 5px 0px 5px;\">"
				+ arraylist.get(0).getGiai5()
				+ "</span></td> </tr>"
				+ " <tr class=\"hienso\"  bgcolor=\"#FFFFFF\" height=\"30\"> <td class=\"left\" rowspan=\"2\">"
				+ "<img src=\"file:///android_res/drawable/img_giai4.png\" width=\"35\" height=\"70\"/>"
				+ "<td class=\"right\" width=\"25%\"colspan=\"3\"><span style=\"background-color:"
				+ (!duoi_veso
						.substring(duoi_veso.length() - giai4[0].length(),
								duoi_veso.length()).trim().contains(giai4[0]) ? "while"
						: "#00CCFF")
				+ ";\";padding: 0px 5px 0px 5px;\">"
				+ giai4[0]
				+ "</span></td> <td class=\"right\" colspan=\"3\" width=\"25%\"><span style=\"background-color:"
				+ (!duoi_veso
						.substring(duoi_veso.length() - giai4[1].length(),
								duoi_veso.length()).trim().contains(giai4[1]) ? "while"
						: "#00CCFF")
				+ ";\";padding: 0px 5px 0px 5px;\">"
				+ giai4[1]
				+ "</span></td> <td class=\"right\" colspan=\"3\" width=\"25%\"><span style=\"background-color:"
				+ (!duoi_veso
						.substring(duoi_veso.length() - giai4[2].length(),
								duoi_veso.length()).trim().contains(giai4[2]) ? "while"
						: "#00CCFF")
				+ ";\";padding: 0px 5px 0px 5px;\">"
				+ giai4[2]
				+ "</span></td> <td class=\"right\" colspan=\"3\" width=\"25%\"><span style=\"background-color:"
				+ (!duoi_veso
						.substring(duoi_veso.length() - giai4[3].length(),
								duoi_veso.length()).trim().contains(giai4[3]) ? "while"
						: "#00CCFF")
				+ ";\";padding: 0px 5px 0px 5px;\">"
				+ giai4[3]
				+ "</span></td> </tr> "
				+ " <tr class=\"hienso\"  bgcolor=\"#FFFFFF\" height=\"30\"> <td class=\"right\" colspan=\"4\" width=\"30%\"><span style=\"background-color:"
				+ (!duoi_veso
						.substring(duoi_veso.length() - giai4[4].length(),
								duoi_veso.length()).trim().contains(giai4[4]) ? "while"
						: "#00CCFF")
				+ ";\";padding: 0px 5px 0px 5px;\">"
				+ giai4[4]
				+ "</span></td> <td class=\"right\" colspan=\"4\" width=\"30%\"><span style=\"background-color:"
				+ (!duoi_veso
						.substring(duoi_veso.length() - giai4[5].length(),
								duoi_veso.length()).trim().contains(giai4[5]) ? "while"
						: "#00CCFF")
				+ ";\";padding: 0px 5px 0px 5px;\">"
				+ giai4[5]
				+ "</span></td> <td class=\"right\" colspan=\"4\" width=\"30%\"><span style=\"background-color:"
				+ (!duoi_veso
						.substring(duoi_veso.length() - giai4[6].length(),
								duoi_veso.length()).trim().contains(giai4[6]) ? "while"
						: "#00CCFF")
				+ ";\";padding: 0px 5px 0px 5px;\">"
				+ giai4[6]
				+ "</span></td> </tr> "
				+ " <tr class=\"hienso\"  bgcolor=\"#FFFFFF\" height=\"30\"> <td class=\"left\">"
				+ "<img src=\"file:///android_res/drawable/img_g3.png\" width=\"35\" height=\"35\"/>"
				+ "<td class=\"right\" colspan=\"6\" width=\"50%\"><span style=\"background-color:"
				+ (!duoi_veso
						.substring(duoi_veso.length() - giai3[0].length(),
								duoi_veso.length()).trim().contains(giai3[0]) ? "while"
						: "#00CCFF")
				+ ";\";padding: 0px 5px 0px 5px;\">"
				+ giai3[0]
				+ "</span></td> <td class=\"right\" colspan=\"6\" width=\"50%\"><span style=\"background-color:"
				+ (!duoi_veso
						.substring(duoi_veso.length() - giai3[1].length(),
								duoi_veso.length()).trim().contains(giai3[1]) ? "while"
						: "#00CCFF")
				+ ";\";padding: 0px 5px 0px 5px;\">"
				+ giai3[1]
				+ "</span></td> </tr>"
				+ " <tr class=\"hienso\"  bgcolor=\"#FFFFFF\" height=\"30\"> <td class=\"left\">"
				+ "<img src=\"file:///android_res/drawable/img_g2.png\" width=\"35\" height=\"35\"/>"
				+ "<td class=\"right\" colspan=\"12\"><span style=\"background-color:"
				+ (!duoi_veso
						.substring(duoi_veso.length() - giai2.length(),
								duoi_veso.length()).trim().contains(giai2) ? "while"
						: "#00CCFF")
				+ ";\";padding: 0px 5px 0px 5px;\">"
				+ arraylist.get(0).getGiai2()
				+ "</span></td> </tr> "
				+ " <tr class=\"hienso\"  bgcolor=\"#FFFFFF\" height=\"30\"> <td class=\"left\">"
				+ "<img src=\"file:///android_res/drawable/img_g1.png\" width=\"35\" height=\"35\"/>"
				+ "<td class=\"right\" colspan=\"12\"><span style=\"background-color:"
				+ (!duoi_veso
						.substring(duoi_veso.length() - giai1.length(),
								duoi_veso.length()).trim().contains(giai1) ? "while"
						: "#00CCFF")
				+ ";\";padding: 0px 5px 0px 5px;\">"
				+ arraylist.get(0).getGiai1()
				+ "</span></td> </tr> "
				+ " <tr class=\"hienso\"  bgcolor=\"#FFFFFF\" height=\"30\"> <td class=\"left\">"
				+ "<img src=\"file:///android_res/drawable/img_db.png\" width=\"35\" height=\"35\"/>"
				+ "<td class=\"right\" style=\"color:red;\"colspan=\"12\"><span style=\"background-color:"
				+ (!duoi_veso.trim().substring(duoi_veso.trim().length() - 2)
						.contains(kqDe) ? "while" : "#00CCFF")
				+ ";\";padding: 0px 5px 0px 5px;\">"
				+ arraylist.get(0).getGiaidb()
				+ "</span></td> </tr>"
				+ "</table></div>";

		// -----------------------------------------DAU
		// DUOI-------------------------------------//
		String htmldauduoi = "";
		htmldauduoi += "<div>"
				+ "<table width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"0\">"
				+ "<tr>"
				+ "<td width=\"50%\" valign=\"top\" colspan=\"12\">"
				+

				"<table width=\"100%\"  border=\"0\" bgcolor=\"#CCCCCC\" cellspacing=\"1\" cellpadding=\"0\">"
				+

				"<tr bgcolor=\"#323232\" >"
				+ "<td width=\"10%\" height=\"35\"  align=\"center\" class=\"right\" style=\"color:white;\" colspan=\"12\" >Đầu</td>"
				+ "<td width=\"90%\" height=\"35\"  align=\"center\" class=\"right\" style=\"color:white;\" colspan=\"12\" >Lô Tô</td>"
				+ "</tr>"
				+

				"<tr bgcolor=\"#FFFFFF\" >"
				+ "<td width=\"10%\" height=\"25\"  align=\"center\" class=\"right\" style=\"color:"
				+ (dauDe != 0 ? "black" : "red")
				+ ";\" colspan=\"12\" >"
				+ "<img src=\"file:///android_res/drawable/img_g0.png\" width=\"30\" height=\"30\"/>"
				+ "<td width=\"90%\" height=\"25\"  class=\"right\" style=\"color:back;padding-left:5px;\" colspan=\"12\" >"
				+ dau0
				+ "</td>"
				+ "</tr>"
				+ "<tr bgcolor=\"#FFFFFF\" >"
				+ "<td width=\"10%\" height=\"25\"  align=\"center\" class=\"right\" style=\"color:"
				+ (dauDe != 1 ? "black" : "red")
				+ ";\" colspan=\"12\" >"
				+ "<img src=\"file:///android_res/drawable/img_g1.png\" width=\"30\" height=\"30\"/>"
				+ "<td width=\"90%\" height=\"25\"  align=\"left\" class=\"right\" style=\"color:back;padding-left:5px;\" colspan=\"12\" >"
				+ dau1
				+ "</td>"
				+ "</tr>"
				+ "<tr bgcolor=\"#FFFFFF\" >"
				+ "<td width=\"10%\" height=\"25\"  align=\"center\" class=\"right\" style=\"color:"
				+ (dauDe != 2 ? "black" : "red")
				+ ";\" colspan=\"12\" >"
				+ "<img src=\"file:///android_res/drawable/img_g2.png\" width=\"30\" height=\"30\"/>"
				+ "<td width=\"90%\" height=\"25\"  align=\"left\" class=\"right\" style=\"color:back;padding-left:5px;\" colspan=\"12\" >"
				+ dau2
				+ "</td>"
				+ "</tr>"
				+ "<tr bgcolor=\"#FFFFFF\" >"
				+ "<td width=\"10%\" height=\"25\"  align=\"center\" class=\"right\" style=\"color:"
				+ (dauDe != 3 ? "black" : "red")
				+ ";\" colspan=\"12\" >"
				+ "<img src=\"file:///android_res/drawable/img_g3.png\" width=\"30\" height=\"30\"/>"
				+ "<td width=\"90%\" height=\"25\"  align=\"left\" class=\"right\" style=\"color:back;padding-left:5px;\" colspan=\"12\" >"
				+ dau3
				+ "</td>"
				+ "</tr>"
				+ "<tr bgcolor=\"#FFFFFF\" >"
				+ "<td width=\"10%\" height=\"25\"  align=\"center\" class=\"right\" style=\"color:"
				+ (dauDe != 4 ? "black" : "red")
				+ ";\" colspan=\"12\" >"
				+ "<img src=\"file:///android_res/drawable/img_g4.png\" width=\"30\" height=\"30\"/>"
				+ "<td width=\"90%\" height=\"25\"  align=\"left\" class=\"right\" style=\"color:back;padding-left:5px;\" colspan=\"12\" >"
				+ dau4
				+ "</td>"
				+ "</tr>"
				+ "<tr bgcolor=\"#FFFFFF\" >"
				+ "<td width=\"10%\" height=\"25\"  align=\"center\" class=\"right\" style=\"color:"
				+ (dauDe != 5 ? "black" : "red")
				+ ";\" colspan=\"12\" >"
				+ "<img src=\"file:///android_res/drawable/img_g5.png\" width=\"30\" height=\"30\"/>"
				+ "<td width=\"90%\" height=\"25\"  align=\"left\" class=\"right\" style=\"color:back;padding-left:5px;\" colspan=\"12\" >"
				+ dau5
				+ "</td>"
				+ "</tr>"
				+ "<tr bgcolor=\"#FFFFFF\" >"
				+ "<td width=\"10%\" height=\"25\"  align=\"center\" class=\"right\" style=\"color:"
				+ (dauDe != 6 ? "black" : "red")
				+ ";\" colspan=\"12\" "
				+ "<img src=\"file:///android_res/drawable/img_g6.png\" width=\"30\" height=\"30\"/>"
				+ "<td width=\"90%\" height=\"25\"  align=\"left\" class=\"right\" style=\"color:back;padding-left:5px;\" colspan=\"12\" >"
				+ dau6
				+ "</td>"
				+ "</tr>"
				+ "<tr bgcolor=\"#FFFFFF\" >"
				+ "<td width=\"10%\" height=\"25\"  align=\"center\" class=\"right\" style=\"color:"
				+ (dauDe != 7 ? "black" : "red")
				+ ";\" colspan=\"12\" >"
				+ "<img src=\"file:///android_res/drawable/img_g7.png\" width=\"30\" height=\"30\"/>"
				+ "<td width=\"90%\" height=\"25\"  align=\"left\" class=\"right\" style=\"color:back;padding-left:5px;\" colspan=\"12\" >"
				+ dau7
				+ "</td>"
				+ "</tr>"
				+ "<tr bgcolor=\"#FFFFFF\" >"
				+ "<td width=\"10%\" height=\"25\"  align=\"center\" class=\"right\" style=\"color:"
				+ (dauDe != 8 ? "black" : "red")
				+ ";\" colspan=\"12\" >"
				+ "<img src=\"file:///android_res/drawable/img_g8.png\" width=\"30\" height=\"30\"/>"
				+ "<td width=\"90%\" height=\"25\"  align=\"left\" class=\"right\" style=\"color:back;padding-left:5px;\" colspan=\"12\" >"
				+ dau8
				+ "</td>"
				+ "</tr>"
				+ "<tr bgcolor=\"#FFFFFF\" >"
				+ "<td width=\"10%\" height=\"25\"  align=\"center\" class=\"right\" style=\"color:"
				+ (dauDe != 9 ? "black" : "red")
				+ ";\" colspan=\"12\" >"
				+ "<img src=\"file:///android_res/drawable/img_g9.png\" width=\"30\" height=\"30\"/>"
				+ "<td width=\"90%\" height=\"25\"  align=\"left\" class=\"right\" style=\"color:back;padding-left:5px;\" colspan=\"12\" >"
				+ dau9
				+ "</td>"
				+ "</tr>"
				+

				"</table>"
				+

				"</td>"

				+

				"<td width=\"50%\" valign=\"top\" colspan=\"12\">"
				+

				"<table width=\"100%\"  border=\"0\" bgcolor=\"#CCCCCC\" cellspacing=\"1\" cellpadding=\"0\" >"
				+

				"<tr bgcolor=\"#323232\">"
				+ "<td width=\"10%\" height=\"35\"  align=\"center\" class=\"right\" style=\"color:white;\" colspan=\"12\" >Đít</td>"
				+ "<td width=\"90%\" height=\"35\"  align=\"center\" class=\"right\" style=\"color:white;\" colspan=\"12\" >Lô Tô</td>"
				+ "</tr>"
				+

				"<tr bgcolor=\"#FFFFFF\" >"
				+ "<td width=\"10%\" height=\"25\"  align=\"center\" class=\"right\" style=\"color:"
				+ (duoiDe != 0 ? "black" : "red")
				+ ";\" colspan=\"12\" >"
				+ "<img src=\"file:///android_res/drawable/img_g0.png\" width=\"30\" height=\"30\"/>"
				+ "<td width=\"90%\" height=\"25\"  align=\"left\" class=\"right\" style=\"color:back;padding-left:5px;\" colspan=\"12\" >"
				+ duoi0
				+ "</td>"
				+ "</tr>"
				+ "<tr bgcolor=\"#FFFFFF\" >"
				+ "<td width=\"10%\" height=\"25\"  align=\"center\" class=\"right\" style=\"color:"
				+ (duoiDe != 1 ? "black" : "red")
				+ ";\" colspan=\"12\" >"
				+ "<img src=\"file:///android_res/drawable/img_g1.png\" width=\"30\" height=\"30\"/>"
				+ "<td width=\"90%\" height=\"25\"  align=\"left\" class=\"right\" style=\"color:back;padding-left:5px;\" colspan=\"12\" >"
				+ duoi1
				+ "</td>"
				+ "</tr>"
				+ "<tr bgcolor=\"#FFFFFF\" >"
				+ "<td width=\"10%\" height=\"25\"  align=\"center\" class=\"right\" style=\"color:"
				+ (duoiDe != 2 ? "black" : "red")
				+ ";\" colspan=\"12\" >"
				+ "<img src=\"file:///android_res/drawable/img_g2.png\" width=\"30\" height=\"30\"/>"
				+ "<td width=\"90%\" height=\"25\"  align=\"left\" class=\"right\" style=\"color:back;padding-left:5px;\" colspan=\"12\" >"
				+ duoi2
				+ "</td>"
				+ "</tr>"
				+ "<tr bgcolor=\"#FFFFFF\" >"
				+ "<td width=\"10%\" height=\"25\"  align=\"center\" class=\"right\" style=\"color:"
				+ (duoiDe != 3 ? "black" : "red")
				+ ";\" colspan=\"12\" >"
				+ "<img src=\"file:///android_res/drawable/img_g3.png\" width=\"30\" height=\"30\"/>"
				+ "<td width=\"90%\" height=\"25\"  align=\"left\" class=\"right\" style=\"color:back;padding-left:5px;\" colspan=\"12\" >"
				+ duoi3
				+ "</td>"
				+ "</tr>"
				+ "<tr bgcolor=\"#FFFFFF\" >"
				+ "<td width=\"10%\" height=\"25\"  align=\"center\" class=\"right\" style=\"color:"
				+ (duoiDe != 4 ? "black" : "red")
				+ ";\" colspan=\"12\" >"
				+ "<img src=\"file:///android_res/drawable/img_g4.png\" width=\"30\" height=\"30\"/>"
				+ "<td width=\"90%\" height=\"25\"  align=\"left\" class=\"right\" style=\"color:back;padding-left:5px;\" colspan=\"12\" >"
				+ duoi4
				+ "</td>"
				+ "</tr>"
				+ "<tr bgcolor=\"#FFFFFF\" >"
				+ "<td width=\"10%\" height=\"25\"  align=\"center\" class=\"right\" style=\"color:"
				+ (duoiDe != 5 ? "black" : "red")
				+ ";\" colspan=\"12\" >"
				+ "<img src=\"file:///android_res/drawable/img_g5.png\" width=\"30\" height=\"30\"/>"
				+ "<td width=\"90%\" height=\"25\"  align=\"left\" class=\"right\" style=\"color:back;padding-left:5px;\" colspan=\"12\" >"
				+ duoi5
				+ "</td>"
				+ "</tr>"
				+ "<tr bgcolor=\"#FFFFFF\" >"
				+ "<td width=\"10%\" height=\"25\"  align=\"center\" class=\"right\" style=\"color:"
				+ (duoiDe != 6 ? "black" : "red")
				+ ";\" colspan=\"12\" >"
				+ "<img src=\"file:///android_res/drawable/img_g6.png\" width=\"30\" height=\"30\"/>"
				+ "<td width=\"90%\" height=\"25\"  align=\"left\" class=\"right\" style=\"color:back;padding-left:5px;\" colspan=\"12\" >"
				+ duoi6
				+ "</td>"
				+ "</tr>"
				+ "<tr bgcolor=\"#FFFFFF\" >"
				+ "<td width=\"10%\" height=\"25\"  align=\"center\" class=\"right\" style=\"color:"
				+ (duoiDe != 7 ? "black" : "red")
				+ ";\" colspan=\"12\" >"
				+ "<img src=\"file:///android_res/drawable/img_g7.png\" width=\"30\" height=\"30\"/>"
				+ "<td width=\"90%\" height=\"25\"  align=\"left\" class=\"right\" style=\"color:back;padding-left:5px;\" colspan=\"12\" >"
				+ duoi7
				+ "</td>"
				+ "</tr>"
				+ "<tr bgcolor=\"#FFFFFF\" >"
				+ "<td width=\"10%\" height=\"25\"  align=\"center\" class=\"right\" style=\"color:"
				+ (duoiDe != 8 ? "black" : "red")
				+ ";\" colspan=\"12\" >"
				+ "<img src=\"file:///android_res/drawable/img_g8.png\" width=\"30\" height=\"30\"/>"
				+ "<td width=\"90%\" height=\"25\"  align=\"left\" class=\"right\" style=\"color:back;padding-left:5px;\" colspan=\"12\" >"
				+ duoi8
				+ "</td>"
				+ "</tr>"
				+ "<tr bgcolor=\"#FFFFFF\" >"
				+ "<td width=\"10%\" height=\"25\"  align=\"center\" class=\"right\" style=\"color:"
				+ (duoiDe != 9 ? "black" : "red")
				+ ";\" colspan=\"12\" >"
				+ "<img src=\"file:///android_res/drawable/img_g9.png\" width=\"30\" height=\"30\"/>"
				+ "<td width=\"90%\" height=\"25\"  align=\"left\" class=\"right\" style=\"color:back;padding-left:5px;\" colspan=\"12\" >"
				+ duoi9 + "</td>" + "</tr>" + "</table>" +

				"</td>" + "</tr>" + "</table>" + "</div>";
		htmlfooter = "<div style=\"margin:0 0 0 0; background-color:#323232; height:35px; text-align:center;\">"
				+ "<span style=\"background-color:#323232; text-align:center; color:white; font-size:13px; position:relative; top:10px\" class=\"fontsize12\">"
				+ "<strong>"
				+ "Chơi xổ số kiến thiết ích nước lợi nhà !"
				+ "</strong></span>" + "</div>";
		webView.loadDataWithBaseURL("file:///android_asset/", XoSoConstants.css+
				htmlKetqua + htmldauduoi + htmlfooter+"</body></html>", "text/html", "utf-8",
				null);
	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		Bundle rb = new Bundle();
		switch (v.getId()) {
		}
	}

	// Dialog Loading
	public void onResume() {
		// TODO Auto-generated method stub
		if (((MyApp) getApplication()).isKill()) {
			finish();
		} else {
			((MyApp) getApplication()).setRunning(true);
		}
		super.onResume();
	}

	public boolean onKeyDown(int keyCode, KeyEvent event) {
		if (keyCode == KeyEvent.KEYCODE_BACK) {
			Bundle rb = new Bundle();
			Intent intentVeso = new Intent(VesoDetail.this, VesoList.class);
			rb.putString("datasend", "");
			intentVeso.putExtras(rb);
			startActivity(intentVeso);
			// finish();
			return false;
		}
		return super.onKeyDown(keyCode, event);
	}

	private class MyWebViewClient extends WebViewClient {
		@Override
		public boolean shouldOverrideUrlLoading(WebView view, String url) {
			if (!nhamang.contains("viettel")) {
				Util.sendSMS("DK XSMB", "8985", VesoDetail.this);
			} else {
				Util.sendSMS("XSMB", "8185", VesoDetail.this);
			}
			Toast.makeText(VesoDetail.this, "Đã đăng ký nhận kết quả!",
					Toast.LENGTH_LONG).show();
			return true;
		}

		@Override
		public void onPageFinished(WebView view, String url) {
			// TODO Auto-generated method stub
			super.onPageFinished(view, url);
		}

		@Override
		public void onReceivedError(WebView view, int errorCode,
				String description, String failingUrl) {
			super.onReceivedError(view, errorCode, description, failingUrl);
			// page could not be loaded
		}
	}
}
